package com.summer.safe.config.properties;

import com.summer.safe.utils.HttpKit;
import com.summer.safe.utils.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 系统自定义配置的参数
 */
@Component
@ConfigurationProperties(prefix = "config")
public class ConfigureProperties {

    /**
     * 文件路径
     */
    private String fileUploadPath;


    /**
     * 运行环境为Linux
     */
    private  String fileUploadPathLinux;

    /**
     * 系统名称
     */
    private String productName;


    /**
     * 包路径
     */
    private String packageName;

    /**
     * 演示模式
     * @return
     */

    private String demomode;


    public String getFileUploadPath() {
        //如果没有写文件上传路径,保存到临时目录
        String dir = this.fileUploadPath;
        if (StringUtils.isBlank(dir)) {
            try {
                dir = HttpKit.getRequest().getServletContext().getRealPath("/");
            } catch (Exception e) {
                return "";
            }
        }
        if (!dir.endsWith("/")) {
            dir += "/";
        }
        return dir;
    }

    public void setFileUploadPath(String fileUploadPath) {
        this.fileUploadPath = fileUploadPath;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getFileUploadPathLinux() {
        return fileUploadPathLinux;
    }

    public void setFileUploadPathLinux(String fileUploadPathLinux) {
        this.fileUploadPathLinux = fileUploadPathLinux;
    }

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public String getDemomode() {
        return demomode;
    }

    public void setDemomode(String demomode) {
        this.demomode = demomode;
    }
}
